﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Generator.AttributeBlockCodeGenerator
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using Microsoft.Internal.Web.Utils;
using System.Collections;
using System.Globalization;
using System.Web.Razor.Parser.SyntaxTree;
using System.Web.Razor.Text;

namespace System.Web.Razor.Generator
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Represents the attributes of the block code generator.</summary>
  public class AttributeBlockCodeGenerator : BlockCodeGenerator
  {
    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Initializes a new instance of the <see cref="T:System.Web.Razor.Generator.AttributeBlockCodeGenerator" /> class.</summary>
    /// <param name="name">The name.</param>
    /// <param name="prefix">The prefix string.</param>
    /// <param name="suffix">The suffix string.</param>
    public AttributeBlockCodeGenerator(
      string name,
      LocationTagged<string> prefix,
      LocationTagged<string> suffix)
    {
      this.Name = name;
      this.Prefix = prefix;
      this.Suffix = suffix;
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the string name of the <see cref="T:System.Web.Razor.Generator.AttributeBlockCodeGenerator" />.</summary>
    /// <returns>The string name of the <see cref="T:System.Web.Razor.Generator.AttributeBlockCodeGenerator" />.</returns>
    public string Name { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the prefix of the code generator.</summary>
    /// <returns>The prefix of the code generator.</returns>
    public LocationTagged<string> Prefix { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the suffix for the code generator.</summary>
    /// <returns>The suffix for the code generator.</returns>
    public LocationTagged<string> Suffix { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Generates code to start the block using the specified parameters.</summary>
    /// <param name="target">The target block.</param>
    /// <param name="context">The code generator context.</param>
    public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
    {
      if (context.Host.DesignTimeMode)
        return;
      context.FlushBufferedStatement();
      context.AddStatement(context.BuildCodeString((Action<CodeWriter>) (cw =>
      {
        if (!string.IsNullOrEmpty(context.TargetWriterName))
        {
          cw.WriteStartMethodInvoke(context.Host.GeneratedClassContext.WriteAttributeToMethodName);
          cw.WriteSnippet(context.TargetWriterName);
          cw.WriteParameterSeparator();
        }
        else
          cw.WriteStartMethodInvoke(context.Host.GeneratedClassContext.WriteAttributeMethodName);
        cw.WriteStringLiteral(this.Name);
        cw.WriteParameterSeparator();
        cw.WriteLocationTaggedString(this.Prefix);
        cw.WriteParameterSeparator();
        cw.WriteLocationTaggedString(this.Suffix);
        cw.WriteLineContinuation();
      })));
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Generates code to end the block using the specified parameters.</summary>
    /// <param name="target">The target block.</param>
    /// <param name="context">The code generator context.</param>
    public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
    {
      if (context.Host.DesignTimeMode)
        return;
      context.FlushBufferedStatement();
      context.AddStatement(context.BuildCodeString((Action<CodeWriter>) (cw =>
      {
        cw.WriteEndMethodInvoke();
        cw.WriteEndStatement();
      })));
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns a string that represents the current object.</summary>
    /// <returns>A string that represents the current object.</returns>
    public override string ToString() => string.Format((IFormatProvider) CultureInfo.CurrentCulture, "Attr:{0},{1:F},{2:F}", (object) this.Name, (object) this.Prefix, (object) this.Suffix);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Determines whether the specified object is equal to the current object.</summary>
    /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
    /// <param name="obj">The object to compare with the current object.</param>
    public override bool Equals(object obj) => obj is AttributeBlockCodeGenerator blockCodeGenerator && string.Equals(blockCodeGenerator.Name, this.Name, StringComparison.Ordinal) && object.Equals((object) blockCodeGenerator.Prefix, (object) this.Prefix) && object.Equals((object) blockCodeGenerator.Suffix, (object) this.Suffix);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns the hash code for this code generator.</summary>
    /// <returns>The hash code for this code generator.</returns>
    public override int GetHashCode() => HashCodeCombiner.Start().Add((IEnumerable) this.Name).Add((object) this.Prefix).Add((object) this.Suffix).CombinedHash;
  }
}
